package wyp.library.ui.view;

import wyp.library.ui.fragment.WypFragment;
import android.content.Context;

public abstract class WypBarItem extends WypGroupView {

	protected Class<?> fragmentClass;
	protected WypFragment fragment;

	public WypBarItem(Context _context, Class<?> _class) {
		super(_context);
		this.fragmentClass = _class;
	}

	public WypFragment getOrCreateFragment() {
		if (fragment == null) {
			try {
				fragment = (WypFragment) fragmentClass.newInstance();
			} catch (InstantiationException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}
		return fragment;
	}

	public WypFragment getFragment() {
		return fragment;
	}

	public void setFragment(WypFragment fragment) {
		this.fragment = fragment;
	}

	public Class<?> getFragmentClass() {
		return fragmentClass;
	}

}
